#include "CExpOrb.h"
#include "ParticleEngine.h"
#include "CPlayer.h"

CExpOrb::CExpOrb()
{
	SetWidth(8);
	SetHeight(8);

	m_nType = OBJ_EXPORB;

	m_nEmitterID = ParticleEngine::GetInstance()->AddEffect(0, 100, GetPosX(), GetPosY(), true);
}
CExpOrb::~CExpOrb()
{
	if(m_nEmitterID != NULL)
		ParticleEngine::GetInstance()->RemoveEffect(m_nEmitterID);
}
void CExpOrb::Update(float fElapsedTime)
{
	if(abs(( int )(m_pPlayer->GetPosX() - GetPosX())) < 200 && abs(( int )(m_pPlayer->GetPosY() - GetPosY()) < 200 ))
	{
		SetVelX((m_pPlayer->GetPosX() - GetPosX())*(2.0f));
		SetVelY((m_pPlayer->GetPosY() - GetPosY())*(2.0f));
	}
	else
	{
		SetVelX(0);
		SetVelY(0);
	}

	ParticleEngine::GetInstance()->SetEmitterInfo (*m_nEmitterID, GetPosX(), GetPosY(), 0);

	CBase::Update(fElapsedTime);
}

void CExpOrb::Render()
{

}
bool CExpOrb::CheckCollision(CBase* pBase)
{
	if(pBase->GetType() == OBJ_PLAYER)
	{
		return true;
	}

	return false;
}